home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-02-06 | 3.6 KB | 141 lines | [TEXT/EDIT] |
- * This demo program opens the printer as a grafport and writes a
- * dragon curve to it. There must be an Imagewriter file on the
- * system disk for this or any other program using prport.sub to run.
- * This program must be compiled with Microsoft FORTRAN 2.1 or later.
- * In addition, it uses NEWHANDLE. The release version of FORTRAN 2.1
- * had a bug in this and other memory manager calls. You should download
- * the changes from Compuserve. It is F77FIX.FOR in DL1 in the MAUG
- * developer's forum.
- * 15 Nov 85 EWG
- * 20 Jan 86 Sent to Compuserve. EWG
-
- program prdrag
-
- implicit none
- integer toolbx
- integer prport ! Print Manager interface.
-
- include memory.inc
- include misc.inc
-
- ! Print Manager function definitions.
- include prport.inc
-
- integer myprport ! Pointer to printer grafport.
- integer prrechdl ! Handle to print record.
- logical ok
- integer n ! Order of curve to draw.
-
- ! Print Manager data structures.
- include prdefs.inc
-
- integer*2 qflag ! Variable to hold bJDocLoop flag.
- integer*1 mystrec(iPrStatSize) ! Status record for PRPICFILE.
-
- write(9,*) 'This demonstration program prints a ' //
- + 'dragon curve to the'
- write(9,*) 'printer using the printer grafport ' //
- + 'feature of the Macintosh.'
- write(9,*) 'Curves of greater order than 10 ' //
- + 'require a large amount of'
- write(9,*) 'disk space, and may not print on your system.'
- type(9,*) 'Enter order of curve: '
- read(9,*) n
-
- call prport(PROPEN) ! Open the print manager.
- prrechdl = toolbx(NEWHANDLE, iPrintSize) ! Get a print record handle.
- call prport(PRINTDEFAULT,prrechdl) ! Fill it out with default values.
- ok = prport(PRSTLDIALOG, prrechdl) ! Let the user set the style.
- ok = prport(PRJOBDIALOG, prrechdl) ! Let the user set up the job.
- if (.not. ok) stop ! User aborted job.
-
- myprport = prport(PROPENDOC, prrechdl, 0, 0) ! Get the printer grafport.
-
- if (prport(PRERROR) .NE. 0) then
- write(9,*) "Printer error ",prport(PRERROR)
- stop
- endif
-
- call prport(PROPENPAGE, myprport, 0) ! Open the first (and only) page.
-
- if (prport(PRERROR) .NE. 0) then
- write(9,*) "Printer error ",prport(PRERROR)
- stop
- endif
-
- call drag(n) ! Output some graphics.
-
- call prport(PRCLOSEPAGE, myprport) ! Close the page.
- call prport(PRCLOSEDOC, myprport) ! Close the printing grafport.
-
- qflag = byte(long(prrechdl)+prJob+bJDocLoop) ! Get print method.
-
- * If the print method is spooled, the actual printing still needs to be done.
- if ((qflag = bSpoolLoop) .AND. (prport(PRERROR) = 0)) then
- call prport(PRPICFILE, prrechdl, 0, 0, 0,
- + toolbx(PTR, mystrec))
- endif
-
- if (prport(PRERROR) .NE. 0) then
- write(9,*) "Printer error ",prport(PRERROR)
- stop
- endif
-
- call prport(PRCLOSE)
-
- end
-
-
- SUBROUTINE DRAG(N)
- * This subroutine draws a dragon curve fractal of order N.
- * Translated from the Pascal program dragon, from
- * "Snowflakes and Dragons" by Matthew Zeidenberg, Macworld,
- * August, 1985.
-
- IMPLICIT NONE
-
- INTEGER XORIG, YORIG, SCALING
- PARAMETER (XORIG=400,YORIG=400,SCALING=200)
-
- INTEGER X1,Y1,X2,Y2,X3,Y3,N
-
- X1=XORIG+SCALING
- Y1=YORIG
- X2=XORIG
- Y2=YORIG-SCALING
- X3=XORIG-SCALING
- Y3=YORIG
-
- CALL DRAGONR(X1,Y1,X2,Y2,X3,Y3,N)
- RETURN
- END
-
- SUBROUTINE DRAGONR(X1,Y1,X2,Y2,X3,Y3,N)
-
- IMPLICIT NONE
-
- INTEGER X4,Y4,X5,Y5,YDIFF,XDIFF
- INTEGER X1,Y1,X2,Y2,X3,Y3,N
- INTEGER*4 TOOLBX
-
- include quickdraw.inc
-
- IF (N.EQ.1) THEN
- CALL TOOLBX(MOVETO,Y1,X1)
- CALL TOOLBX(LINETO,Y2,X2)
- CALL TOOLBX(LINETO,Y3,X3)
- ELSE
- X4=((X1+X3)/2)
- Y4=((Y1+Y3)/2)
- X5=X3+(X2-X4)
- Y5=Y3+(Y2-Y4)
-
- CALL DRAGONR(X2,Y2,X4,Y4,X1,Y1,N-1)
- CALL DRAGONR(X2,Y2,X5,Y5,X3,Y3,N-1)
- ENDIF
-
- RETURN
- END
-
-
-